import sqlite3


def create_table(c):
    c.execute("create table commodity(id int primary key, title text, href text, price real)")


def insert(c, value):
    c.execute("insert into commodity values (?, ?, ?, ?)", (value[0], value[1], value[2], value[3]))


def insert_batch(c, values):
    for value in values:
        insert(c, value)


def delete(c, value):
    c.execute("delete from commodity where id =" + str(value))


def update(c, value):
    c.execute("update commodity set price = ? where id = ?", (value[3], value[0]))


def select(c):
    for row in c.execute('select * from commodity order by price'):
        print(row)


conn = sqlite3.connect('example.db')
c = conn.cursor()
# create_table(c)
value = [1, '23', '23423', 27]
values = [[2, 'sd', 'fd', 213], [3, 'sad', 'fdsf', 213], [4, 'sad', 'ert', 24]]
# insert(c, value)
# insert_batch(c, values)
# update(c, value)
delete(c, 3)
select(c)
conn.commit()
conn.close()
